{extend name="public/layer_base"}
{block name="main"}

<div class="layui-body layui-tab-content site-demo site-demo-body">
    <div class="layui-tab-item layui-show">
        <div class="layui-main">
            <div id="LAY_preview">
                {eq name="type" value=""}
                    <form class="layui-form" action="{:url('api_explain')}" id="send_form" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">接口说明</label>
                        <div class="layui-input-block">
                            <textarea id="api_msg" style="display: none;">{$data.api_msg|default=''}</textarea>
                            <input type="hidden" name="api_msg" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="id" value="{$data.id|default=0}">
                            <button class="layui-btn send-btn" lay-submit="" lay-filter="send_form">立即提交</button>
                            <!--<button class="layui-btn" type="submit">立即提交</button>-->
                        </div>
                    </div>
                </form>
                {else /}
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
                        <legend>接口说明</legend>
                    </fieldset>

                    <blockquote class="layui-elem-quote layui-quote-nm">
                        {$data.api_msg}
                    </blockquote>
                {/eq}
            </div>
        </div>
    </div>
</div>
{/block}

{block name="javascript"}
<script>
    layui.use('layedit', function(){
        var layedit = layui.layedit, $ = layui.jquery;
        var content = layedit.build('api_msg', {
            height: 180 //设置编辑器高度
        }); //建立编辑器

        // 使用jquery ajax提交数据，默认获取不到编辑器内容，需要手动将内容放入表单域
        $(".send-btn").click(function () {
            $('input[name="api_msg"]').val(layedit.getContent(content));
            console.log($('input[name="api_msg"]').val());
        });
    });
</script>
{/block}